<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Russian Dolls for the Maximum Stable Set Problem: graph/graph.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Russian Dolls for the Maximum Stable Set Problem
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">graph.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="graph_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#ifndef GRAPH_H_</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define GRAPH_H_</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="bitmap_8h.html" title="Macros and inline functions for bitwise operations on bitmaps using bit-parallelism.">bitmap.h</a>&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;stdlib.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;malloc.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="code" href="structGraph.html">   24</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="code" href="structGraph.html#a6196749068b51bc6bd9c4b81bbf68b5b">   25</a></span>&#160;        <span class="keywordtype">size_t</span>          <a class="code" href="structGraph.html#a6196749068b51bc6bd9c4b81bbf68b5b" title="Number of vertices.">n</a>;                      </div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="code" href="structGraph.html#a6880fc5fa7af2603a45ad9b0f6f613ba">   26</a></span>&#160;        <span class="keywordtype">size_t</span>          <a class="code" href="structGraph.html#a6880fc5fa7af2603a45ad9b0f6f613ba" title="Number of edges.">m</a>;                      </div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="code" href="structGraph.html#a6f303bf74775f34a843de5ea22b37461">   27</a></span>&#160;        <a class="code" href="bitmap_8h.html#a5047cbfad0b49c9f1c7a57ddbee2009a" title="Bitmap node&#39;s type.">NODETYPE</a> *      <a class="code" href="structGraph.html#a6f303bf74775f34a843de5ea22b37461" title="Bitmap adjacency matrix.">matrix</a>;         </div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="code" href="structGraph.html#a487c7597059d07c7a5fe9fcab5d47ebc">   28</a></span>&#160;        <span class="keywordtype">size_t</span>          <a class="code" href="structGraph.html#a487c7597059d07c7a5fe9fcab5d47ebc" title="Of the bitmap, in bytes.">matrixsize</a>; </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb">   29</a></span>&#160;        <span class="keywordtype">size_t</span>          <a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb" title="Logarithmic of the row&#39;s number of nodes.">logrowsize</a>;     </div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="code" href="structGraph.html#af4905f210d8e490c0cce09c318462147">   30</a></span>&#160;        <span class="keywordtype">int</span>                     <a class="code" href="structGraph.html#af4905f210d8e490c0cce09c318462147" title="Size of the maximum clique.">maxcq</a>;          </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="code" href="structGraph.html#a22821e1cd387ed0e72c6493be9dd4a3b">   31</a></span>&#160;        <span class="keywordtype">double</span>          <a class="code" href="structGraph.html#a22821e1cd387ed0e72c6493be9dd4a3b" title="Weight o the maximum clique.">maxwcq</a>;         </div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;} <a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a>;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="code" href="graph_8h.html#ab71bc4f2f0ce94074f64128cdd4c5b68">   34</a></span>&#160;<span class="preprocessor">#define ROWINDEX(g,i) ((i) &lt;&lt; g-&gt;logrowsize)                                                                    </span></div>
<div class="line"><a name="l00035"></a><span class="lineno"><a class="code" href="graph_8h.html#a02b968cb87903d74caa04a7abec8ffb2">   35</a></span>&#160;<span class="preprocessor">#define PAIRINDEX(g, i, j) (ROWINDEX(g,i)+NODEIDX(j))                                           </span></div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="code" href="graph_8h.html#a7097c2b8f64f735bf5e9e0a93f54d9e9">   36</a></span>&#160;<span class="preprocessor">#define NEIG(g,i) (g-&gt;matrix+ROWINDEX(g,i))                                                                     </span></div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="code" href="graph_8h.html#ad60f540e053e4645ad93ab6773f83d5b">   37</a></span>&#160;<span class="preprocessor">#define HASEDGE(g, i, j) ISINNODE(NEIG(g,i)[NODEIDX(j)],IDXINNODE(j))           </span></div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="code" href="graph_8h.html#a4a7e45e23b4bca3c2b6863ab3b298387">   38</a></span>&#160;<span class="preprocessor">#define ADDEDGE(g, i, j) ADDTONODE(NEIG(g,i)[NODEIDX(j)],IDXINNODE(j))          </span></div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="code" href="graph_8h.html#a95e9c8b7a675bcf29d05e04965d3b168">   39</a></span>&#160;<span class="preprocessor">#define DELEDGE(g, i, j) DELFROMNODE(NEIG(g,i)[NODEIDX(j)],IDXINNODE(j))        </span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> inline_ceillog2(<span class="keywordtype">int</span> n) {</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;        <span class="keywordtype">int</span> c = 0;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        <span class="keywordtype">int</span> l = 0;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;        <span class="keywordflow">while</span> (n &gt; 1) {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;                c |= (n &amp; 1);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;                n &gt;&gt;= 1;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                l++;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        }</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        l += c;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="keywordflow">return</span> l;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="comment">//Graph * newGraph(size_t n);</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;<span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> * newGraph(<span class="keywordtype">size_t</span> n) {</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        <a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> * ret = (<a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> *) malloc(<span class="keyword">sizeof</span>(<a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a>));</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        ret-&gt;<a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb" title="Logarithmic of the row&#39;s number of nodes.">logrowsize</a> = (inline_ceillog2(n)-<a class="code" href="bitmap_8h.html#afced88f944530b6dfb95807ae45120a6" title="Logarithmic of BSIZE.">LOGB</a>);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <span class="keywordflow">if</span> (ret-&gt;<a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb" title="Logarithmic of the row&#39;s number of nodes.">logrowsize</a> &lt; 0)</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;                ret-&gt;<a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb" title="Logarithmic of the row&#39;s number of nodes.">logrowsize</a> = 0;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        ret-&gt;<a class="code" href="structGraph.html#a487c7597059d07c7a5fe9fcab5d47ebc" title="Of the bitmap, in bytes.">matrixsize</a> = ((1 &lt;&lt; ret-&gt;<a class="code" href="structGraph.html#a2df1bf4a587bb0b52f82ad56d12313bb" title="Logarithmic of the row&#39;s number of nodes.">logrowsize</a>)*n) &lt;&lt; <a class="code" href="bitmap_8h.html#ac6f0b43ab85743ce5de50d53bda6de62" title="Logarithmic of WSIZE.">LOGW</a>;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        ret-&gt;<a class="code" href="structGraph.html#a6196749068b51bc6bd9c4b81bbf68b5b" title="Number of vertices.">n</a> = n;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        ret-&gt;<a class="code" href="structGraph.html#a6f303bf74775f34a843de5ea22b37461" title="Bitmap adjacency matrix.">matrix</a> = (<a class="code" href="bitmap_8h.html#a5047cbfad0b49c9f1c7a57ddbee2009a" title="Bitmap node&#39;s type.">NODETYPE</a> *) malloc(ret-&gt;<a class="code" href="structGraph.html#a487c7597059d07c7a5fe9fcab5d47ebc" title="Of the bitmap, in bytes.">matrixsize</a>);</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        memset(ret-&gt;<a class="code" href="structGraph.html#a6f303bf74775f34a843de5ea22b37461" title="Bitmap adjacency matrix.">matrix</a>, 0, ret-&gt;<a class="code" href="structGraph.html#a487c7597059d07c7a5fe9fcab5d47ebc" title="Of the bitmap, in bytes.">matrixsize</a>);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">return</span> ret;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;}</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="comment">//void delGraph(Graph * g);</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> delGraph(<a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> * g) {</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        free(g-&gt;<a class="code" href="structGraph.html#a6f303bf74775f34a843de5ea22b37461" title="Bitmap adjacency matrix.">matrix</a>);</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;}</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="preprocessor">#ifdef _DEBUG_</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> printNeigNodes(<a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> * g, <span class="keywordtype">int</span> i) {</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        <span class="keywordtype">int</span> lastnode = <a class="code" href="bitmap_8h.html#ab8ce022c2df6a106a810279b8fa255fb" title="Node index in the bitmap of element i.">NODEIDX</a>(g-&gt;<a class="code" href="structGraph.html#a6196749068b51bc6bd9c4b81bbf68b5b" title="Number of vertices.">n</a>-1);</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        <span class="keywordtype">int</span> node;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        printf(<span class="stringliteral">&quot;NEIG(%d): [&quot;</span>,i);</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        <span class="keywordflow">for</span> (node = lastnode; node &gt;= 0; node--)</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;                printf(FORMX, <a class="code" href="graph_8h.html#a7097c2b8f64f735bf5e9e0a93f54d9e9" title="Bitmap corresponding to the neigborhood of i in g.">NEIG</a>(g,i)[node]);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        printf(<span class="stringliteral">&quot;]\n&quot;</span>);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;}</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> printNodes(<a class="code" href="structGraph.html" title="Bitmap implementation of a graph adjacency matrix.">Graph</a> * g) {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <span class="keywordflow">for</span> (i = 0; i &lt; g-&gt;<a class="code" href="structGraph.html#a6196749068b51bc6bd9c4b81bbf68b5b" title="Number of vertices.">n</a>; i++)</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                printNeigNodes(g, i);</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;}</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* GRAPH_H_ */</span><span class="preprocessor"></span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 14 2014 13:23:35 for Russian Dolls for the Maximum Stable Set Problem by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
